#ifndef ELBLOCKS_H
#define ELBLOCKS_H

//#include <QDialog>

#include <QtWidgets/QDialog>
class ELAbstractShape;
class ELShapeO;

namespace Ui {
class ELBlocks;
}

class ELBlocks : public QDialog
{
    Q_OBJECT
    
public:
    explicit ELBlocks(QWidget *parent = 0);
    ~ELBlocks();
protected:
    void paintEvent(QPaintEvent *);
    void keyPressEvent(QKeyEvent *);

private:
    Ui::ELBlocks *ui;
private:
    void drawGameTable();
    void fillBlockWithColor(QPainter *pPainter, int row, int col, QColor *fillColor);
    void checkFullLinesOrIsOver();
    void findPeek();
    bool isLineEmptyAtIndex(int index);
    bool isLineFullAtIndex(int index);
    void setLevel();
    int clearFullLines();
    void resetGame();

    enum {NumBlocksVertical = 20, NumBlocksHorizontal=10, TableLeft = 10
          , TableTop=10, BlockWidth = 30, KindOfShapes = 7, TimerTickNormal = 1000};
    bool isPlaying;
    bool ** hasBlock;
    QColor ***colors;
    QTimer * timer;
    ELAbstractShape * shapes[KindOfShapes];
    int currentShape, nextShape;
    QColor nextShapeColor;
    int score, level, lines, peek;
    bool isEndKeyPressed;
    bool isGameOver;

private slots:
    void startBtnClicked();
    void gameTick();
};

#endif // ELBLOCKS_H
